package com.ajk.server.dao.provider;

import com.ajk.server.model.ReportPart;

public class PartProvider {
	
	public String update(ReportPart reportPart) {
		StringBuilder sb = new StringBuilder();
		sb.append("update t_report_part set id = id ");
		if(reportPart.getName() != null) {
			sb.append(" ,name = #{name}");
		}
		if(reportPart.getPartImage() != null) {
			sb.append(" ,part_image = #{partImage}");
		}
		if(reportPart.getFilename() != null) {
			sb.append(",filename = #{filename}");
		}
		if(reportPart.getStatus() != null) {
			sb.append(" ,status = #{status}");
		}
		if(reportPart.getPartNo() != null) {
			sb.append(" ,part_no = #{partNo}");
		}
		sb.append(" where id = #{id}");
		return sb.toString();
	}

	public String getPartList(ReportPart reportPart) {
		StringBuilder sb = new StringBuilder();
		sb.append("select * from t_report_part where 1 = 1  ");
		if(reportPart.getStatus() != null) {
			sb.append(" and status = #{status}");
		}
		sb.append(" order by id desc");
		if(reportPart.getStart() != null && reportPart.getLimit() != null) {
			sb.append(" limit #{start},#{limit}");
		}
		return sb.toString();
	}
}
